package edu.ped.android.adapter;

import edu.ped.android.nfc.R;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListActivitiesAdapter extends BaseAdapter {

	private String[] mNames;
	private Drawable[] mIcons;
	private Context mContext;
	private LayoutInflater inflater;
	
	class ViewHolder{
		ImageView iv;
		TextView tv;
	}
	
	public ListActivitiesAdapter(Context context,String[] names, Drawable[] icons) {
		mContext=context;
		mNames=names;
		mIcons=icons;
		inflater = LayoutInflater.from(mContext);
	}

	public int getCount() {
		return mNames.length;
	}

	public Object getItem(int arg0) {
		return null;
	}

	public long getItemId(int arg0) {
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder holder;

		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.listview_activities_item, null);
			holder.tv = (TextView) convertView.findViewById(R.listview_activities_item.text_activity);
			holder.iv = (ImageView) convertView.findViewById(R.listview_activities_item.icon_activity);
			holder.tv.setText(mNames[position]);
			holder.iv.setImageDrawable(mIcons[position]);
			convertView.setTag(mNames[position]);
		} 
		return convertView;
	}
}
